package com.taotao.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.taotao.common.bean.EUTreeNode;
import com.taotao.common.bean.TaotaoResult;
import com.taotao.service.ContentCategoryService;

@Controller
@RequestMapping("/content/category")
public class ContentCategoryController {
	
	@Autowired
	private ContentCategoryService contentCategoryService;
	
	@RequestMapping("/list")
	@ResponseBody
	public List<EUTreeNode> getContentCategoryList(@RequestParam(value="id",defaultValue="0")long parentId) {
		List<EUTreeNode> contentCatList = contentCategoryService.getContentCatList(parentId);
		return contentCatList;
	}
	
	@RequestMapping("/create")
	@ResponseBody
	public TaotaoResult createNode(long parentId,String name) {
		TaotaoResult contentCate = contentCategoryService.createContentCate(parentId, name);
		return contentCate;
	}
	
	@RequestMapping("/delete")
	@ResponseBody
	public TaotaoResult deleteNode(long id) {
		TaotaoResult contentCate = contentCategoryService.deleteContentCate(id);
		return contentCate;
	}
	
	@RequestMapping("/update")
	@ResponseBody
	public TaotaoResult updateNode(long id,String name) {
		TaotaoResult contentCate = contentCategoryService.updateContentCate(id, name);
		return contentCate;
	}
	
}
